# import csv
# from bs4 import BeautifulSoup
# import requests
# # a = "Fri Aug 13 14:05:20 +0800 2010"
# # a = time.strptime(a, "%a %b %d %H:%M:%S %z %Y")
# # a = time.strftime("%Y-%m-%d %H:%M:%S", a)
# # print(a)
#
# import datetime
# #
# # a = '08-29'
# # a += '-' + str(datetime.datetime.now().year)
# # a = time.strptime(a, "%m-%d-%Y")
# # a = time.strftime("%Y-%m-%d %H:%M:%S", a)
# # print(a)
# # csvFile = open("content.csv", 'w', newline='')
# # csv_writer = csv.writer(csvFile, dialect='excel')
# # csv_writer.writerow(['id', 'mid', '创建日期', '转发', '评论', '赞', '微博内容'])
# # csvFile.close()
# # with open("content.txt", 'w', newline='', encoding='utf-8') as csvFile:
# #     csv_writer = csv.writer(csvFile)
# #     csv_writer.writerow(['id', 'mid', '创建日期', '转发', '评论', '赞', '微博内容'])
# headers = {'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
#            'Accept-Encoding': 'gzip, deflate, br',
#            'Accept-language': 'zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2',
#            'Host': 'm.weibo.cn',
#            'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:61.0) Gecko/20100101 Firefox/61.0'
#            # 'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.62 Safari/537.36'
# }
# #
# # com_heads = {'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
# #              'Accept-Encoding': 'gzip, deflate, br',
# #              'Accept-language': 'zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2',
# #              'Cache-Control': 'max-age=0',
# #              'Connection': 'keep-alive',
# #              'Host': 'weibo.com',
# #              'Upgrade-Insecure-Requests': '1',
# #              'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:61.0) Gecko/20100101 Firefox/61.0'
# # }
# #
# # cookie = {
# #     'TC-Page-G0': '07e0932d682fda4e14f38fbcb20fac81',
# #     'SUB': '_2AkMs0oqlf8NxqwJRmP4QzGrka4xyygzEieKajnt-JRMxHRl-yT9jqlBStRB6B1KkSmUlrFvbG-hpAm968-I9F934crUi',
# #     'SUBP': '0033WrSXqPxfM72-Ws9jqgMF55529P9D9W58IiKn2y3fi_d8JOVEFyP6; TC-V5-G0=2bdac3b437dd23e235b79a3d6922ea06',
# #     '_s_tentry': 'passport.weibo.com',
# #     'Apache': '1525847561678.829.1536034175830',
# #     'SINAGLOBAL': '1525847561678.829.1536034175830',
# #     'ULV': '1536034175873:1:1:1:1525847561678.829.1536034175830:',
# #     'WBStorage': 'e8781eb7dee3fd7f|undefined',
# #     'hibext_instdsigdipv2': '1'
# # }
# #
# session = requests.Session()
# # r = session.get('https://f.us.sinaimg.cn/003q6N1Zlx07mNeAu5r201040200iJm70k010.mp4?label=mp4_ld&template=640x360.27&Expires=1536038544&ssig=fmis5Wml2l&KID=unistore,video')
# # bsObj = BeautifulSoup(r.text, features="html.parser")
# video_url = 'https://f.us.sinaimg.cn/003q6N1Zlx07mNeAu5r201040200iJm70k010.mp4?label=mp4_ld&template=640x360.27&Expires=1536038544&ssig=fmis5Wml2l&KID=unistore,video'
# video_file_name = video_url.split('?')[0].split('/')[-1]
# video = requests.get(video_url)
# with open(video_file_name, 'wb') as video_file:
#     video_file.write(video.content)
# # object_id = '1034:4272516567605862'
# # object_id_b = object_id.split(':')[1]
# # params = {'fid': object_id}
# # url = 'https://weibo.com/tv/v/'+ object_id_b
# # print(url)
# # r = session.get(url, headers=com_heads, cookies=cookie)
# # print(r.text)
from urllib.parse import unquote

print(unquote('http%3A%2F%2Ff.us.sinaimg.cn%2F001stjATlx07nElntsow01040200hwp80k010.mp4%3Flabel%3Dmp4_hd%26template%3D852x480.25%26Expires%3D1537198497%26ssig%3Dy2nGx2xTAN%26KID%3Dunistore%2Cvideo&fid=1034:4284583299200682&ztshow=&logo=2&uid=&vf=vshow'))
url = 'http%3A%2F%2Ff.us.sinaimg.cn%2F001stjATlx07nElntsow01040200hwp80k010.mp4%3Flabel%3Dmp4_hd%26template%3D852x480.25%26Expires%3D1537198044%26ssig%3DgSaKjVPGtZ%26KID%3Dunistore%2Cvideo&480=http%3A%2F%2Ff.us.sinaimg.cn%2F001stjATlx07nElntsow01040200hwp80k010.mp4%3Flabel%3Dmp4_hd%26template%3D852x480.25%26Expires%3D1537198044%26ssig%3DgSaKjVPGtZ%26KID%3Dunistore%2Cvideo&720=http%3A%2F%2Ff.us.sinaimg.cn%2F001qrNyIlx07nElrbSNO01040200uYkS0k010.mp4%3Flabel%3Dmp4_720p%26template%3D1280x720.26%26Expires%3D1537198044%26ssig%3DWf5inNq9ab%26KID%3Dunistore%2Cvideo&qType=720'
url = url.split('720=')[-1]
print(unquote(url))